package com.hfut.jpoa.service.impl;

import java.text.ParseException;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hfut.jpoa.common.dto.ResultDto;
import com.hfut.jpoa.common.util.DateUtils;
import com.hfut.jpoa.dao.LogDAO;
import com.hfut.jpoa.dto.LogDTO;
import com.hfut.jpoa.model.Log;
import com.hfut.jpoa.model.User;
import com.hfut.jpoa.service.LogService;
import com.hfut.jpoa.service.exception.LogException;

public class LogServiceImpl implements LogService
{
	private static final Logger LOGGER = LoggerFactory
	        .getLogger(DispatchServiceImpl.class);

	/**
	 * 日志服务
	 */
	private LogDAO logDAO;

	public ResultDto<Log> queryInfoForPage(LogDTO condition)
	        throws LogException
	{
		ResultDto<Log> findInfoForPage = logDAO.findInfoForPage(condition);
		return findInfoForPage;
	}

	public void insert(Log condition) throws LogException
	{
		// TODO Auto-generated method stub

	}

	public void update(Log record) throws LogException
	{
		// TODO Auto-generated method stub

	}

	public Log findInfo(Log condition) throws LogException
	{
		// TODO Auto-generated method stub
		return null;
	}

	public boolean codeValidator(Log condition) throws LogException
	{
		// TODO Auto-generated method stub
		return false;
	}

	public List<Log> queryList(Log condition) throws LogException
	{
		// TODO Auto-generated method stub
		return null;
	}

	public void saveLog(Log Log) throws LogException
	{
		// TODO Auto-generated method stub

	}

	public void packageUser(List<Log> result, List<User> lstUsers)
	        throws LogException
	{
		// TODO Auto-generated method stub

	}

	public void insertLog(String operater, String operaterIp, String model,
	        String type, String note, String content) throws LogException
	{
		Log log = new Log();
		log.setCode(type);
		try
		{
			log.setOccurDate(DateUtils.getNowDate());
		} catch (ParseException e)
		{
			LOGGER.error("获取当前时间异常：", e);
			throw new LogException("获取当前时间异常：", e);
		}
		log.setOperator(operater);
		log.setOperatorIp(operaterIp);
		log.setOther(note);
		log.setContent(content);
		log.setUnitCode(model);
		logDAO.insertSelective(log);
	}

	public LogDAO getLogDAO()
	{
		return logDAO;
	}

	public void setLogDAO(LogDAO logDAO)
	{
		this.logDAO = logDAO;
	}

}
